package com.cn.lxf.sharding_test;

import com.cn.lxf.sharding_test.service.HealthRecordService;
import com.cn.lxf.sharding_test.service.UserService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;

import java.sql.SQLException;

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
@MapperScan(basePackages = "com.cn.lxf.sharding_test.mapper")
public class ShardingTestApplication {

    public static void main(String[] args) throws SQLException {
//        SpringApplication.run( ShardingTestApplication.class, args );
        try (ConfigurableApplicationContext applicationContext = SpringApplication.run(ShardingTestApplication.class, args)) {
            UserService userService = applicationContext.getBean(UserService.class);
            //userService.processUsers();
//            userService.getUsers();

            //广播表
//        	HealthLevelService healthLevelService = applicationContext.getBean( HealthLevelService.class);
//        	healthLevelService.processLevels();

            //绑定表
//        	HealthRecordService healthRecordService = applicationContext.getBean( HealthRecordService.class);
//        	healthRecordService.processHealthRecords();

            //查询recode信息

        	HealthRecordService healthRecordService = applicationContext.getBean( HealthRecordService.class);
        	healthRecordService.processAllRecords();

//        	HintService hintService = applicationContext.getBean(HintService.class);
//        	hintService.processWithHintValueForShardingDatabases();
//        	hintService.processWithHintValueForShardingDatabasesAndTables();
//        	hintService.processWithHintValueMaster();
        }
    }

}
